<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('单据查询列表')" />
	<th:block th:include="include :: list-css" />
    <style>
        .layui-tab-title{border-color: #ccc !important;}
        .layui-this{color: rgb(0, 135, 250) !important;background: none !important;}
        .layui-tab-brief > .layui-tab-title .layui-this:after, .layui-tab-brief > .layui-tab-more li.layui-this:after{border-color:  rgb(0, 135, 250) !important;}
        .mid-content {overflow: auto;}
    </style>
</head>
<body class="no-skin">
<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="addbtn">
			<i class="dhicon dh-lujing1089"></i> 新增
		</div>
        <!-- <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="deleteBatch">
			<i class="dhicon dh-remove"></i> 删除
		</div> -->
        <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="exportbtn">
			<i class="dhicon dh-zu4250_2_2"></i> 导出
		</div>
		<div class="layui-btn layui-table-tools importbtn-bg'"
			lay-event="importBatch">
			<i class="dhicon dh-upload"></i> 批量导入
		</div>
    </div>
</script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var gridColumns = [[${gridColumns}]],
        business = [[${storage}]],
        buttonState = [[${buttonState}]],
        businessName = gridColumns.moduleAlias,
        passwordAuthentication = [[${passwordAuthentication}]],
        moduleTable = [[${moduleTable}]];
    /*]]>*/
    var prefix = "/storage/"+business;
	var tableUrl = prefix + "/list",
	openRowUrl = "/storage/"+(business.split('/')[1]?business.split('/')[0]:business)+"/edit?nid=";
	exportUrl = prefix + "/export";
	delUrl = prefix+"/delete";
</script>
<th:block th:include="listinclude :: container" />
<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: searchJS" />
<th:block th:include="listinclude :: list-templeat" />


<script type="text/javascript">
	/*
    var $,layer,form,table,laydate,element;//定义layui模块
    layui.use(['laydate', 'table','form','layer','jquery','util','element'], function () {
         $ = layui.$,layer = layui.layer,form = layui.form,table = layui.table,laydate = layui.laydate,util = layui.util,element=layui.element;
	    // //监听行双击事件
        setTimeout(function(){
            table.on('rowDouble(ftable)', function (obj) {
                top.layui.index.openTabsPage(prefix+ "/edit?guid="+obj.data.guid,'库存修改单 - 编辑')
            });
        },500)
    })
    */
    var $, layer, form, table, laydate, util, laydate, wherestr = {}, moduleUrl;
    var scroll = {X: '', Y: ''};
    var pagenum = 1
    layui.use(['table', 'form', 'layer', 'jquery', 'laydate', 'element'], function () {
        $ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, laydate = layui.laydate, element = layui.element;
        serachRender();//查询条件初始渲染集合
        sessionStorage.setItem(moduleTable + 'checkdata', '')
        var isbtn = true
        $.tablelist.init({
            elem: '#dhtable',
            url: tableUrl,
            where: getWherestr(),
            totalRow: gridColumns.totalRow,
            cols: [gridColumns.gridBody],
            toolbar: '#toolbar',
            defaultToolbar: [{title: '列设置', layEvent: 'fieldSet', icon: 'layui-icon-set'}]
            ,height: 'full-46'
            ,done: function (res, curr, count) {
            }
        });


        //头工具栏事件
        table.on('toolbar(ftable)', function (obj) {
            var checkStatus = table.checkStatus('dhtable');
            switch (obj.event) {
                case 'addbtn'://新增
    				top.layui.index.openTabsPage(prefix+ "/add", businessName + ' - 新增')
    				break;
                case 'exportbtn'://导出
                    $.ajax({
                        url: exportUrl,
                        type: 'GET',
                        data: getWherestr(),
                        dataType: 'json',
                        beforeSend: function () {
                            showloadings(true);
                        },
                        success: function (result) {
                            if (result.code == 0) {
                                window.location.href = ctx + "common/download?fileName=" + encodeURIComponent(result.msg) + "&delete=" + true;
                                parent.$('.page-loading').hide();//页面进行了跳转刷新，需要手动关闭页面的加载动画
                            } else if (result.code == web_status.WARNING) {
                                $.modal.alertWarning(result.msg)
                            } else {
                                $.modal.alertError(result.msg);
                            }
                            showloadings(false);
                        }
                    });
                    break;
                case 'deleteBatch'://删除
                    var objpage = sessionStorage.getItem(moduleTable + 'checkdata')
                    if (!objpage) {
                        layer.msg("请先选择数据！");
                    } else {
                        let msg = "确定要删除么？";
                        if (moduleTable === "TCG_PURCHASEORDER"){
                            msg = "该操作将删除所有关联的采购计划单!";
                        }
                        $.modal.confirmCom(msg, function (result) {
                            var infoItems = JSON.parse(objpage)
                            $.operate.post(delUrl, {infoItems: JSON.stringify(infoItems)}, function (result) {
                                setTimeout(function () {
                                    table.reload('dhtable', {page: {curr: 1}, where: getWherestr()});
                                }, 1000);
                            });
                        });
                    }

                    break;
                case 'importBatch':// 批量导入
                	var w=($(window).width()*0.9);
                	var h=($(window).height() - 50);
            		layer.open({
            			type: 2,
            			area: [w+'px', h +'px'],
            			fix: true,
            			maxmin: false,
            			shadeClose: true,
            			shade:0.4,
            			title: "批量导入",
            			content: '/storage/stockope/toImportBatch'
            		});

                    break;

                case 'fieldSet'://列设置
                    filedSet(moduleTable);
                    break;
            	}
            ;
        });

        //监听工具条
        table.on('tool(ftable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'workday'://工作时间设定——工作日
                    var pd = [];
                    pd.push(data);
                    $.operate.post('/hr/attendanceworkdateset/editworkday', {'attendanceWorkDateSetItems': JSON.stringify(pd)}, function (res) {
                        if (res.code == 0) table.reload('dhtable');
                    });
                    break;
                default:
                    break;
            }
        });
        //监听排序事件
        table.on('sort(ftable)', function (obj) {
            $.tablelist.sort('dhtable', obj);
        });
    })
</script>

</body>
</html>